knitr document van Steensel lab

Epigenetic Screening

Introduction

This script tries to find out which drugs are able to significantly alter indel pattern formation in RSTP2#5 cells in different chromatin contexts. In the end, the aim is to couple biological relevance to these changes.

Description of Data

How to make a good rendering table:

column1 column2 column3
1 2 3
a b c

Data processing

Path, Libraries, Parameters and Useful Functions

## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## Loading required package: grid
## ========================================
## ComplexHeatmap version 2.0.0
## Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/
## Github page: https://github.com/jokergoo/ComplexHeatmap
## Documentation: http://jokergoo.github.io/ComplexHeatmap-reference
## 
## If you use it in published research, please cite:
## Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
##   genomic data. Bioinformatics 2016.
## ========================================
## ========================================
## circlize version 0.4.8
## CRAN page: https://cran.r-project.org/package=circlize
## Github page: https://github.com/jokergoo/circlize
## Documentation: http://jokergoo.github.io/circlize_book/book/
## 
## If you use it in published research, please cite:
## Gu, Z. circlize implements and enhances circular visualization 
##   in R. Bioinformatics 2014.
## ========================================
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine
## Loading required package: graph
## Loading required package: BiocGenerics
## Loading required package: parallel
## 
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:parallel':
## 
##     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
##     clusterExport, clusterMap, parApply, parCapply, parLapply,
##     parLapplyLB, parRapply, parSapply, parSapplyLB
## The following object is masked from 'package:gridExtra':
## 
##     combine
## The following objects are masked from 'package:dplyr':
## 
##     combine, intersect, setdiff, union
## The following objects are masked from 'package:stats':
## 
##     IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
## 
##     anyDuplicated, append, as.data.frame, basename, cbind, colnames,
##     dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
##     grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
##     order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
##     rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
##     union, unique, unsplit, which, which.max, which.min
## 
## Attaching package: 'graph'
## The following object is masked from 'package:circlize':
## 
##     degree
## 
## Loading required package: futile.logger
## Loading required package: magrittr
## 
## Attaching package: 'magrittr'
## The following object is masked from 'package:tidyr':
## 
##     extract
## 
## Attaching package: 'ggpubr'
## The following object is masked from 'package:VennDiagram':
## 
##     rotate
## 
## Attaching package: 'Laurae'
## The following object is masked from 'package:data.table':
## 
##     setDF

Custom functions

Functions used thoughout this script.

Data import

Compute relevant logratios and divide per concentration

Bring dataframe to heatmap plotting format

Annotate heatmap columns and rows

## Warning in `!=.default`(indel.data$Target, c("Negative Control", "MRN", : longer
## object length is not a multiple of shorter object length
## Warning in is.na(e1) | is.na(e2): longer object length is not a multiple of
## shorter object length
# Add type of chr. mark (repressive or active)
type <- mapping_mean_long %>% select(variable, type) %>% unique() %>%
  remove_rownames %>% column_to_rownames(var="variable")

# Add annotation of barcodes (based on clustering in 0_Clone5_Annotation.Rmd)
barcode.annotation <- unique(as.data.frame(indel.data.high$barcode))

## Manually added these tags: check/rewrite this
barcode.annotation$cluster[c(18,2)] <- "Active Promoter/Enhancer"
barcode.annotation$cluster[c(12,8)] <- "H3K9me2/3 Domain"
barcode.annotation$cluster[c(3,14,4,17)] <- "Active Gene Body"
barcode.annotation$cluster[c(5,13,6,15)] <- "LAD"
barcode.annotation$cluster[c(7,16)] <- "No Marks Present"
barcode.annotation$cluster[c(1,10,9,11)] <- "H3K27me3 Domain"

barcode.annotation <- barcode.annotation %>% remove_rownames() %>%
  column_to_rownames("indel.data.high$barcode")


# Change colors of annotations
colors <- brewer.pal(length(unique(barcode.annotation$cluster)), "Pastel2")
names(colors) <- unique(barcode.annotation$cluster)

annotation_colors_scr = list(
  cluster = colors,
  type = c(Active="#669966", Repressive="grey90"),
  target = c(HDAC="#60988D", HAT="#C6D0A8", Sirtuin="#8FCAAC",
             HMT="#FDCDAC", DNMT="#D69C81", `Histone Demethylase`="#FFF2AE",
             HIF="#E3DCD5", JAK="#C8D7E2", PIM="#9AB8C4", `Aurora Kinase`="#F4CAE4",
             PARP="#CB546F", `Epigenetic Reader Domain`= "#476D61", `DNA-PK`="#E07A43"
             ))



# Order the annotation legend
ordered_marks <- c("Active Promoter/Enhancer", "Active Gene Body", "No Marks Present", "H3K27me3 Domain",  "H3K9me2/3 Domain", "LAD")
annotation_colors_scr$cluster <- annotation_colors_scr$cluster[ordered_marks]

ordered_marks2 <- c("DNA-PK","Epigenetic Reader Domain", "HDAC",  "Sirtuin", "HAT", 
                    "Histone Demethylase", "HMT", "DNMT", 
                    "HIF", "JAK", "PIM",
                    "Aurora Kinase", "PARP")
annotation_colors_scr$target <- annotation_colors_scr$target[ordered_marks2]

Next, I want to create heatmaps to visualize the effect of each individual drug on each of the 18 barcodes.

Results

logratio heatmap of each individual drug vs. barcode

## This heatmap contains too much information -> We need to decrease the number of drugs ## Only drugs that change the logratio

Now plot the same for the efficiency

Heatmap for one certain target group

## Warning in melt(.): The melt generic in data.table has been passed a data.frame
## and will attempt to redirect to the relevant reshape2 method; please note that
## reshape2 is deprecated, and this redirection is now deprecated as well. To
## continue using melt methods from reshape2 while both libraries are attached,
## e.g. melt.list, you can prepend the namespace like reshape2::melt(.). In the
## next version, this warning will become an error.
## Using barcode as id variables
## Warning in dcast(., variable ~ barcode, value.var = "value"): The dcast
## generic in data.table has been passed a data.frame and will attempt to redirect
## to the reshape2::dcast; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. Please do this redirection yourself like
## reshape2::dcast(.). In the next version, this warning will become an error.
## Warning in melt(.): The melt generic in data.table has been passed a data.frame
## and will attempt to redirect to the relevant reshape2 method; please note that
## reshape2 is deprecated, and this redirection is now deprecated as well. To
## continue using melt methods from reshape2 while both libraries are attached,
## e.g. melt.list, you can prepend the namespace like reshape2::melt(.). In the
## next version, this warning will become an error.
## Using barcode as id variables
## Warning in dcast(., variable ~ barcode, value.var = "value"): The dcast
## generic in data.table has been passed a data.frame and will attempt to redirect
## to the reshape2::dcast; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. Please do this redirection yourself like
## reshape2::dcast(.). In the next version, this warning will become an error.
## Warning in melt(.): The melt generic in data.table has been passed a data.frame
## and will attempt to redirect to the relevant reshape2 method; please note that
## reshape2 is deprecated, and this redirection is now deprecated as well. To
## continue using melt methods from reshape2 while both libraries are attached,
## e.g. melt.list, you can prepend the namespace like reshape2::melt(.). In the
## next version, this warning will become an error.
## Using barcode as id variables
## Warning in dcast(., variable ~ barcode, value.var = "value"): The dcast
## generic in data.table has been passed a data.frame and will attempt to redirect
## to the reshape2::dcast; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. Please do this redirection yourself like
## reshape2::dcast(.). In the next version, this warning will become an error.
## Warning in melt(.): The melt generic in data.table has been passed a data.frame
## and will attempt to redirect to the relevant reshape2 method; please note that
## reshape2 is deprecated, and this redirection is now deprecated as well. To
## continue using melt methods from reshape2 while both libraries are attached,
## e.g. melt.list, you can prepend the namespace like reshape2::melt(.). In the
## next version, this warning will become an error.
## Using barcode as id variables
## Warning in dcast(., variable ~ barcode, value.var = "value"): The dcast
## generic in data.table has been passed a data.frame and will attempt to redirect
## to the reshape2::dcast; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. Please do this redirection yourself like
## reshape2::dcast(.). In the next version, this warning will become an error.
## Warning in melt(.): The melt generic in data.table has been passed a data.frame
## and will attempt to redirect to the relevant reshape2 method; please note that
## reshape2 is deprecated, and this redirection is now deprecated as well. To
## continue using melt methods from reshape2 while both libraries are attached,
## e.g. melt.list, you can prepend the namespace like reshape2::melt(.). In the
## next version, this warning will become an error.
## Using barcode as id variables
## Warning in dcast(., variable ~ barcode, value.var = "value"): The dcast
## generic in data.table has been passed a data.frame and will attempt to redirect
## to the reshape2::dcast; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. Please do this redirection yourself like
## reshape2::dcast(.). In the next version, this warning will become an error.
## Warning in melt(.): The melt generic in data.table has been passed a data.frame
## and will attempt to redirect to the relevant reshape2 method; please note that
## reshape2 is deprecated, and this redirection is now deprecated as well. To
## continue using melt methods from reshape2 while both libraries are attached,
## e.g. melt.list, you can prepend the namespace like reshape2::melt(.). In the
## next version, this warning will become an error.
## Using barcode as id variables
## Warning in dcast(., variable ~ barcode, value.var = "value"): The dcast
## generic in data.table has been passed a data.frame and will attempt to redirect
## to the reshape2::dcast; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. Please do this redirection yourself like
## reshape2::dcast(.). In the next version, this warning will become an error.

Efficiency/logratio overlay

## (polygon[GRID.polygon.194], polygon[GRID.polygon.195], polygon[GRID.polygon.196], polygon[GRID.polygon.197], text[GRID.text.198], text[GRID.text.199], text[GRID.text.200], text[GRID.text.201], text[GRID.text.202])

Next step is to import the chromatin data to generate a correlation matrix between the logratio change of each drug and the chromatin data. A correlation is calculated by comparing logratio changes of drug A for each barcode with ChIP data of ChIP dataset A for each barcode etc.

Correlation between ChIP data and logratio changes

## Warning in melt(mapping_mean_chip, variable.name = "barcode", value.name =
## "mean"): The melt generic in data.table has been passed a data.frame and will
## attempt to redirect to the relevant reshape2 method; please note that reshape2
## is deprecated, and this redirection is now deprecated as well. To continue using
## melt methods from reshape2 while both libraries are attached, e.g. melt.list,
## you can prepend the namespace like reshape2::melt(mapping_mean_chip). In the
## next version, this warning will become an error.
## Using ChIP as id variables
## Warning in dcast(., barcode ~ ChIP, value.var = "mean"): The dcast generic
## in data.table has been passed a data.frame and will attempt to redirect
## to the reshape2::dcast; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. Please do this redirection yourself like
## reshape2::dcast(.). In the next version, this warning will become an error.

# There are some interesting drug-induced changes that can be explained by certain chromatin marks - this can be looked at in more detail

Cluster-specific effects: now, instead of correlating each chromatin mark against drug-induced change, I try to correlate the drug-induced change against the chromatin clusters

## Warning in dcast(clusters, `unique(indel.data$barcode)` ~ cluster): The dcast
## generic in data.table has been passed a data.frame and will attempt to redirect
## to the reshape2::dcast; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. Please do this redirection yourself like
## reshape2::dcast(clusters). In the next version, this warning will become an
## error.
## Using 'cluster' as value column. Use 'value.var' to override

## [1] 0.08515303
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## cluster      5  2.370  0.4741    5.77 0.000759 ***
## Residuals   30  2.465  0.0822                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Again, some interesting stuff

HDAC vs Integration 17

# H3K27me3 seems to correlate with the logratio change induced by HDACs

Correlation plots individual drugs

HDAC correlation

## Warning in dcast(., Var2 ~ Drug): The dcast generic in data.table has been
## passed a data.frame and will attempt to redirect to the reshape2::dcast; please
## note that reshape2 is deprecated, and this redirection is now deprecated as
## well. Please do this redirection yourself like reshape2::dcast(.). In the next
## version, this warning will become an error.
## Using 'logratio.platenorm' as value column. Use 'value.var' to override
## Warning in melt(.): The melt generic in data.table has been passed a data.frame
## and will attempt to redirect to the relevant reshape2 method; please note that
## reshape2 is deprecated, and this redirection is now deprecated as well. To
## continue using melt methods from reshape2 while both libraries are attached,
## e.g. melt.list, you can prepend the namespace like reshape2::melt(.). In the
## next version, this warning will become an error.
## Using ChIP as id variables

## Warning in melt(h3k27.data, id.vars = c("rowname", "H3K27me3")): The melt
## generic in data.table has been passed a data.frame and will attempt to redirect
## to the relevant reshape2 method; please note that reshape2 is deprecated, and
## this redirection is now deprecated as well. To continue using melt methods from
## reshape2 while both libraries are attached, e.g. melt.list, you can prepend the
## namespace like reshape2::melt(h3k27.data). In the next version, this warning
## will become an error.

MC-1293 HDAC1 correlation

## Warning in melt(.): The melt generic in data.table has been passed a data.frame
## and will attempt to redirect to the relevant reshape2 method; please note that
## reshape2 is deprecated, and this redirection is now deprecated as well. To
## continue using melt methods from reshape2 while both libraries are attached,
## e.g. melt.list, you can prepend the namespace like reshape2::melt(.). In the
## next version, this warning will become an error.
## Using integration as id variables

Drug dose response

## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

## Warning in dcast(., barcode ~ Drug, value.var = "mean.logratio.bc.drug"): The
## dcast generic in data.table has been passed a data.frame and will attempt to
## redirect to the reshape2::dcast; please note that reshape2 is deprecated, and
## this redirection is now deprecated as well. Please do this redirection yourself
## like reshape2::dcast(.). In the next version, this warning will become an error.

## Warning in dcast(., barcode ~ Drug, value.var = "mean.logratio.bc.drug"): The
## dcast generic in data.table has been passed a data.frame and will attempt to
## redirect to the reshape2::dcast; please note that reshape2 is deprecated, and
## this redirection is now deprecated as well. Please do this redirection yourself
## like reshape2::dcast(.). In the next version, this warning will become an error.

## Warning in dcast(., barcode ~ Drug, value.var = "mean.logratio.bc.drug"): The
## dcast generic in data.table has been passed a data.frame and will attempt to
## redirect to the reshape2::dcast; please note that reshape2 is deprecated, and
## this redirection is now deprecated as well. Please do this redirection yourself
## like reshape2::dcast(.). In the next version, this warning will become an error.
## Warning in melt(., variable.name = "Drug", value.name = "cor"): The melt generic
## in data.table has been passed a data.frame and will attempt to redirect to the
## relevant reshape2 method; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. To continue using melt methods from
## reshape2 while both libraries are attached, e.g. melt.list, you can prepend the
## namespace like reshape2::melt(.). In the next version, this warning will become
## an error.
## Using ChIP as id variables
## Warning in melt(., variable.name = "Drug", value.name = "cor"): The melt generic
## in data.table has been passed a data.frame and will attempt to redirect to the
## relevant reshape2 method; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. To continue using melt methods from
## reshape2 while both libraries are attached, e.g. melt.list, you can prepend the
## namespace like reshape2::melt(.). In the next version, this warning will become
## an error.
## Using ChIP as id variables
## Warning in melt(., variable.name = "Drug", value.name = "cor"): The melt generic
## in data.table has been passed a data.frame and will attempt to redirect to the
## relevant reshape2 method; please note that reshape2 is deprecated, and this
## redirection is now deprecated as well. To continue using melt methods from
## reshape2 while both libraries are attached, e.g. melt.list, you can prepend the
## namespace like reshape2::melt(.). In the next version, this warning will become
## an error.
## Using ChIP as id variables
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

Exporting potential data.

Session Info

## [1] "Run time:  29.28544 secs"
## [1] "/DATA/usr/m.trauernicht/projects/EpiScreen/code/epigenetic-screening-on-trip-clone"
## [1] "Fri May  1 13:40:45 2020"
## R version 3.6.3 (2020-02-29)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 16.04.6 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/libblas/libblas.so.3.6.0
## LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] parallel  grid      stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] Laurae_0.0.0.9001    ggpubr_0.2.5         magrittr_1.5        
##  [4] tibble_3.0.1         ggforce_0.3.1        VennDiagram_1.6.20  
##  [7] futile.logger_1.4.3  tidyr_1.0.0          Pigengene_1.10.0    
## [10] graph_1.62.0         BiocGenerics_0.30.0  RColorBrewer_1.1-2  
## [13] gridExtra_2.3        gridGraphics_0.4-1   pheatmap_1.0.12     
## [16] circlize_0.4.8       ComplexHeatmap_2.0.0 data.table_1.12.8   
## [19] ggbeeswarm_0.6.0     ggplot2_3.2.1        outliers_0.14       
## [22] dplyr_0.8.5         
## 
## loaded via a namespace (and not attached):
##   [1] Cubist_0.2.3          colorspace_1.4-1      ggsignif_0.6.0       
##   [4] rjson_0.2.20          ellipsis_0.3.0        dynamicTreeCut_1.63-1
##   [7] htmlTable_1.13.3      GlobalOptions_0.1.1   base64enc_0.1-3      
##  [10] clue_0.3-57           rstudioapi_0.10       farver_2.0.1         
##  [13] bit64_0.9-7           AnnotationDbi_1.46.1  mvtnorm_1.0-12       
##  [16] codetools_0.2-16      splines_3.6.3         doParallel_1.0.15    
##  [19] impute_1.58.0         robustbase_0.93-5     libcoin_1.0-5        
##  [22] knitr_1.28            polyclip_1.10-0       Formula_1.2-3        
##  [25] WGCNA_1.68            cluster_2.1.0         GO.db_3.8.2          
##  [28] png_0.1-7             rrcov_1.4-9           compiler_3.6.3       
##  [31] backports_1.1.5       assertthat_0.2.1      Matrix_1.2-18        
##  [34] lazyeval_0.2.2        tweenr_1.0.1          formatR_1.7          
##  [37] acepack_1.4.1         htmltools_0.4.0       tools_3.6.3          
##  [40] partykit_1.2-5        gtable_0.3.0          glue_1.3.1           
##  [43] reshape2_1.4.4        Rcpp_1.0.3            Biobase_2.44.0       
##  [46] vctrs_0.2.4           preprocessCore_1.46.0 iterators_1.0.12     
##  [49] inum_1.0-1            xfun_0.12             fastcluster_1.1.25   
##  [52] stringr_1.4.0         lifecycle_0.2.0       DEoptimR_1.0-8       
##  [55] MASS_7.3-51.5         scales_1.1.0          lambda.r_1.2.4       
##  [58] yaml_2.2.0            C50_0.1.3             memoise_1.1.0        
##  [61] rpart_4.1-15          latticeExtra_0.6-29   stringi_1.4.6        
##  [64] RSQLite_2.2.0         S4Vectors_0.22.1      pcaPP_1.9-73         
##  [67] foreach_1.4.7         checkmate_1.9.4       shape_1.4.4          
##  [70] rlang_0.4.5           pkgconfig_2.0.3       matrixStats_0.55.0   
##  [73] evaluate_0.14         lattice_0.20-38       purrr_0.3.3          
##  [76] labeling_0.3          htmlwidgets_1.5.1     bit_1.1-15           
##  [79] tidyselect_0.2.5      robust_0.4-18.2       plyr_1.8.6           
##  [82] R6_2.4.1              IRanges_2.18.3        Hmisc_4.3-0          
##  [85] fit.models_0.5-14     DBI_1.1.0             pillar_1.4.3         
##  [88] foreign_0.8-74        withr_2.1.2           survival_3.1-8       
##  [91] nnet_7.3-12           crayon_1.3.4          bnlearn_4.5          
##  [94] futile.options_1.0.1  rmarkdown_2.0         jpeg_0.1-8.1         
##  [97] GetoptLong_0.1.8      blob_1.2.0            Rgraphviz_2.28.0     
## [100] digest_0.6.23         stats4_3.6.3          munsell_0.5.0        
## [103] beeswarm_0.2.3        vipor_0.4.5